import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import PersonalView from '../views/PersonalView.vue'
import IndexView from '../views/IndexView.vue'
import AboutView from '../views/AboutView.vue'
import CartView from '../views/CartView.vue'
import LoginView from '../views/LoginView.vue'
import RegisterView from '../views/RegisterView.vue'
import OrderManageView from '../views/OrderManageView.vue'
import CommentsManageView from '../views/CommentsManageView.vue'
import SelfInfoView from '../views/SelfInfoView.vue'
import AddressManageView from '../views/AddressManageView.vue'
import LoopManageView from '../views/LoopManageView.vue'
import LoopView from '../views/LoopView.vue'
import BooksManageView from '../views/BooksManageView.vue'
import ProductDetailView from '../views/ProductDetailView.vue'
import ProductShowView from '../views/ProductShowView.vue'
import PayView from '../views/PayView.vue'
import SetOrderView from '../views/SetOrderView.vue'
import SearchView from '../views/SearchView.vue'
import UserView from '../views/UserView.vue'
import Validator from 'vue-validator'

import Loop from '../components/Loop.vue'
Vue.use(Validator)


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: LoginView
  },
  {
    path: '/index',
    name: 'index',
    component: IndexView,
    children: [,
      {
        path: '',
        name: 'home',
        // component: HomeView
        component: () => import(/* webpackChunkName: "about" */ '../views/HomeView.vue'),
      },
      {
        path: 'about',
        name: 'about',
        component: AboutView
      },
      // {
      //   path: 'cart',
      //   name: 'cart',
      //   component: CartView
      // },
      {
        path: 'pShow',
        name: 'pShow',
        component: ProductShowView
      },
      {
        path: 'Loop',
        name: 'Loop',
        component: Loop
      },
      {
        path: 'pDetail',
        name: 'pDetail',
        component: ProductDetailView
      },
      {
        path: 'pay',
        name: 'pay',
        component: PayView
      },
      {
        path: 'setOrder',
        name: 'setOrder',
        component: SetOrderView
      },
      {
        path: 'personal',
        name: 'personal',
        component: PersonalView,
        children: [
          {
            path: 'selfinfo',
            name: 'selfinfo',
            component: SelfInfoView
          },
          {
            path: 'comment',
            name: 'comment',
            component: CommentsManageView
          },
          {
            path: 'order',
            name: 'order',
            component: OrderManageView
          },
          {
            path: 'address',
            name: 'address',
            component: AddressManageView
          },
          {
            path: 'loop',
            name: 'loop',
            component: LoopManageView
          },
          {
            path: 'books',
            name: 'books',
            component: BooksManageView
          },
          {
            path: 'cart',
            name: 'cart',
            component: CartView
          },
        ]
      },
      // {
      //   path: 'about',
      //   name: 'about',
      //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
      // }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView
  },
  {
    path: '/register',
    name: 'register',
    component: RegisterView
  },
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
